package com.jchy.renderit.displayable;
 
import com.jchy.renderit.core.Hit;
import com.jchy.renderit.core.Point;

public class Checked extends Plane
{

    private java.awt.Color secondaryColor;
    public double size;

    public Checked()
    {
        secondaryColor=new java.awt.Color(0,0,0);
        size=100.0;
    }    

    public void setSecondaryColorInt(int red, int green, int blue)
    {
        secondaryColor=new java.awt.Color(red, green, blue);
    }

    public int getSecondaryColorRed()
    {
        return secondaryColor.getRed();
    }

    public int getSecondaryColorGreen()
    {
        return secondaryColor.getGreen();
    }

    public int getSecondaryColorBlue()
    {
        return secondaryColor.getBlue();
    }

    @Override
    public Hit intersect(Point prp, Point vrp)
    {
        Hit aHit = super.intersect(prp,vrp);

        if(aHit.isHit)
        {
            if((int)(Math.ceil(aHit.location.x/size)+Math.ceil(aHit.location.y/size))%2==0)
            aHit.color=new java.awt.Color(getSecondaryColorRed(),
                                          getSecondaryColorGreen(),
                                          getSecondaryColorBlue());
        }

        return aHit;        
    }

    @Override
    public String toString()
    {
        String result = super.toString();
        result=result+"\nSecondary Color: (" + secondaryColor.getRed() + ", " +
                                               secondaryColor.getGreen() + "," +
                                               secondaryColor.getBlue() + ") ";
        return result;
    }

}

